/**
 * 
 */
package org.stars.util.diagnostic;

import org.stars.util.diagnostic.StackTraceDiagnosticHandler;

/**
 * Sistema di diagnostica di default. Di default tale sistema
 * di diagnostica è abilitato.
 * 
 * @author Francesco Benincasa (908099)
 *
 */
public class DefaultStackTraceDiagnosticHandler implements
		StackTraceDiagnosticHandler {

	/**
	 * serial id
	 */
	private static final long serialVersionUID = 4094215902214267790L;
		
	/**
	 * 
	 */
	protected int lowerBoundIndex;
	
	/**
	 * 
	 */
	protected int upperBoundIndex;	
	
	/**
	 * costruttore.
	 */
	public DefaultStackTraceDiagnosticHandler()
	{
		enabled=true;
		lowerBoundIndex=0;
		upperBoundIndex=6;
	}
	
	/* (non-Javadoc)
	 * @see it.insiel.daostars.diagnostic.StackTraceDiagnosticHandler#canBeginDisplay(int, java.lang.StackTraceElement)
	 */
	@Override
	public boolean canBeginDisplay(int index, StackTraceElement element) {
		return true;
	}

	/* (non-Javadoc)
	 * @see it.insiel.daostars.diagnostic.StackTraceDiagnosticHandler#canStopDisplay(int, java.lang.StackTraceElement)
	 */
	@Override
	public boolean canStopDisplay(int index, StackTraceElement element) {
		return false;
	}

	/* (non-Javadoc)
	 * @see it.insiel.daostars.diagnostic.StackTraceDiagnosticHandler#getLowerBoundIndex()
	 */
	@Override
	public int getLowerBoundIndex() {		
		return lowerBoundIndex;
	}

	/* (non-Javadoc)
	 * @see it.insiel.daostars.diagnostic.StackTraceDiagnosticHandler#getStringToDisplay(int, java.lang.StackTraceElement)
	 */
	@Override
	public String getStringToDisplay(int index, StackTraceElement element) {
		String sApp;
		sApp=" class "+element.getClassName()+" method "+element.getMethodName()+" line "+element.getLineNumber()+" ";
		return sApp;
	}

	/* (non-Javadoc)
	 * @see it.insiel.daostars.diagnostic.StackTraceDiagnosticHandler#getUpperBoundIndex()
	 */
	@Override
	public int getUpperBoundIndex() {		
		return upperBoundIndex;
	}

	/* (non-Javadoc)
	 * @see it.insiel.daostars.diagnostic.StackTraceDiagnosticHandler#setLowerBoundIndex(int)
	 */
	@Override
	public void setLowerBoundIndex(int lowerIndex) {
		lowerBoundIndex=lowerIndex;		
	}

	/* (non-Javadoc)
	 * @see it.insiel.daostars.diagnostic.StackTraceDiagnosticHandler#setUpperBoundIndex(int)
	 */
	@Override
	public void setUpperBoundIndex(int upperLimit) {
		upperBoundIndex=upperLimit;		
	}
	
	/**
	 * indica se visualizzare o meno lo stack trace
	 */
	protected boolean enabled;

	/* (non-Javadoc)
	 * @see it.insiel.daostars.diagnostic.StackTraceDiagnosticHandler#isEnabled()
	 */
	@Override
	public boolean isEnabled() {
		return enabled;
	}

	/* (non-Javadoc)
	 * @see it.insiel.daostars.diagnostic.StackTraceDiagnosticHandler#setEnabled(boolean)
	 */
	@Override
	public void setEnabled(boolean value) {
		enabled=value;
		
	}


}
